// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   CMITime.java

package com.iphaeton.lms.course.scorm12.datamodel.cmi;

import java.io.Serializable;
import java.util.StringTokenizer;

public class CMITime
    implements Serializable
{

    public CMITime(String timeString)
    {
        StringTokenizer st = new StringTokenizer(timeString, ":");
        String lmsHours = st.nextToken();
        String lmsMinutes = st.nextToken();
        String lmsSeconds = st.nextToken();
        CMIHours = Integer.parseInt(lmsHours);
        CMIMinutes = Integer.parseInt(lmsMinutes);
        CMISeconds = Float.valueOf(lmsSeconds).floatValue();
    }

    public int getHours()
    {
        return CMIHours;
    }

    public int getMinutes()
    {
        return CMIMinutes;
    }

    public float getSeconds()
    {
        return CMISeconds;
    }

    public void setHours(int iHours)
    {
        CMIHours = iHours;
    }

    public void setMinutes(int iMinutes)
    {
        CMIMinutes = iMinutes;
    }

    public void setSeconds(float iSeconds)
    {
        CMISeconds = iSeconds;
    }

    public String toString()
    {
        String temp = new String("0");
        String hours = Integer.toString(CMIHours, 10);
        if(hours.length() == 1)
            hours = "0" + hours;
        else
        if(hours.length() == 0)
            hours = "00";
        String minutes = Integer.toString(CMIMinutes, 10);
        if(minutes.length() == 1)
            minutes = "0" + minutes;
        else
        if(minutes.length() == 0)
            minutes = "00";
        String seconds = Float.toString(CMISeconds);
        if(seconds.length() == 1)
            seconds = "0" + seconds;
        else
        if(seconds.length() == 0)
            seconds = "00";
        return hours + ":" + minutes + ":" + seconds;
    }

    public void add(CMITime addTime)
    {
        int newHours = 0;
        int newMinutes = 0;
        float newSeconds = 0.0F;
        newSeconds = CMISeconds + addTime.CMISeconds;
        if((double)newSeconds > 60D)
        {
            newSeconds -= 60F;
            newMinutes++;
        }
        newSeconds = (float)(int)(newSeconds * 100F) / 100F;
        newMinutes = newMinutes + CMIMinutes + addTime.CMIMinutes;
        if(newMinutes > 60)
        {
            newMinutes -= 60;
            newHours++;
        }
        newHours = newHours + CMIHours + addTime.CMIHours;
        CMIHours = newHours;
        CMIMinutes = newMinutes;
        CMISeconds = newSeconds;
    }

    private static final long serialVersionUID = 0xf5941a8ed8f19fa1L;
    private int CMIHours;
    private int CMIMinutes;
    private float CMISeconds;
}
